<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ page import="com.wing.sys.domain.*"%>
<%@ include file="/pub/includ.jsp"%>
<%
	String authlayouts = (String)request.getAttribute("authlayouts");
	String authtemplates = (String)request.getAttribute("authtemplates");
	String authlookfeels = (String)request.getAttribute("authlookfeels");
	String authfuns = (String)request.getAttribute("authfuns");
	String siteId = (String)request.getAttribute("siteId");
%>
<script type="text/javascript">
	var save = function(){
		return "success";
	}
	$(function() {
		$( "#tabs" ).tabs();
		loadGird("frmtemplate", 1);
		loadGird("frmlayout", 1);
		loadGird("frmlookfeel", 1);
		loadGird("frmfunction", 1);
	});
				
	var callback_frmlayout = function(rows, frm) {
       $.each(rows, function(i, n){
    	   var row = $("#"+frm+" .template").clone().removeClass("template");
   			       var keyValue = n.id;
	       row.find(".klId").attr("value",n.id);
	       
	       if("<%=authlayouts %>".indexOf(n.id) != -1 )
	   			row.find(".klId").attr("checked",true);
	       row.find(".klId").attr("id",n.id);
	       row.find(".klId").click(function(){ajaxauth("<%=Auth.TYPE_LAYOUT %>",n.id)});
	   	
	       row.find(".klname").text(n.name);
	   	
	       row.find(".klfilename").text(n.filename);
	   	
	       row.find(".klorder_num").text(n.order_num);
	   	
	       row.find(".klispub").text(n.ispub=="<%=com.wing.cms.domain.Layout.ISPUB_TRUE %>"?"是":"否");
	   	
 		   row.attr("id","ready"+i);
           row.attr("class","tr_nbw");
           row.appendTo("#"+frm+" .grid");
       });   
	}
	var callback_frmtemplate = function(rows, frm) {
       $.each(rows, function(i, n){
    	   var row = $("#"+frm+" .template").clone().removeClass("template");
   			       var keyValue = n.id;
	       row.find(".klId").attr("value",n.id);
	   	
	       if("<%=authtemplates %>".indexOf(n.id) != -1 )
	   			row.find(".klId").attr("checked",true);
	       row.find(".klId").attr("id",n.id);
	       row.find(".klId").click(function(){ajaxauth("<%=Auth.TYPE_TEMPLATE %>",n.id)});
	   			
	       row.find(".klname").text(n.name);
	   	
	       row.find(".klpicpath").text(n.picpath);
	   	
	       row.find(".klftlpath").text(n.ftlpath);
	   	
	       row.find(".klpictype").text(n.pictype);
	   	
	       row.find(".klispub").text(n.ispub=="<%=com.wing.cms.domain.Template.ISPUB_TRUE %>"?"是":"否");
	   	
 		   row.attr("id","ready"+i);
           row.attr("class","tr_nbw");
           row.appendTo("#"+frm+" .grid");
       });   
	}
	var callback_frmlookfeel = function(rows, frm) {
       $.each(rows, function(i, n){
    	   var row = $("#"+frm+" .template").clone().removeClass("template");
   			       var keyValue = n.id;
	       row.find(".klId").attr("value",n.id);
	   	
	       if("<%=authlookfeels %>".indexOf(n.id) != -1 )
	   			row.find(".klId").attr("checked",true);
	       row.find(".klId").attr("id",n.id);
	       row.find(".klId").click(function(){ajaxauth("<%=Auth.TYPE_LOOKFEL %>",n.id)});
	   			
	       row.find(".klname").text(n.name);
	   	
	       row.find(".klfilename").text(n.filename);
	   	
	       row.find(".klorder_num").text(n.order_num);
	   	
	       row.find(".klispub").text(n.ispub=="<%=com.wing.cms.domain.Lookfeel.ISPUB_TRUE %>"?"是":"否");
	   	
 		   row.attr("id","ready"+i);
           row.attr("class","tr_nbw");
           row.appendTo("#"+frm+" .grid");
       });   
	}
	var callback_frmfunction = function(rows, frm) {
       $.each(rows, function(i, n){
    	   var row = $("#"+frm+" .template").clone().removeClass("template");
   			       var keyValue = n.id;
	       row.find(".klId").attr("value",n.id);
	       if("<%=authfuns %>".indexOf(n.id) != -1 )
	   			row.find(".klId").attr("checked",true);
	       row.find(".klId").attr("id",n.id);
	       row.find(".klId").click(function(){ajaxauth("<%=Auth.TYPE_FUNCTION %>",n.id)});
	   			
	       row.find(".klname").text(n.name);
	   	
	       row.find(".klfun_code").text(n.picpath);
	   	
	       row.find(".klispub").text(n.ispub=="<%=com.wing.cms.domain.Template.ISPUB_TRUE %>"?"是":"否");
	   	
 		   row.attr("id","ready"+i);
           row.attr("class","tr_nbw");
           row.appendTo("#"+frm+" .grid");
       });   
	}
	
	function ajaxauth(type,id){
		var state = $("#"+id).attr("checked");
		$.ajax({
		   type: "POST",
		   url: "<%=path %>/cms/site/ajaxauth",
		   data: "siteId=<%=siteId %>&type="+type+"&id="+id+"&state="+state,
		   success: function(msg){
		   }
		});
	}
</script>
<body style="margin: 0">
	<div id="tabs" style="width:98%">
		<ul>
			<li><a href="#tabs-1">框架授权</a></li>
			<li><a href="#tabs-2">模板授权</a></li>
			<li><a href="#tabs-3">皮肤授权</a></li>
			<li><a href="#tabs-4">功能授权</a></li>
		</ul>
		<div id="tabs-1" style="overflow: scroll;height:250px">
						<form name="frmlayout" method="post" style="margin: 0" action="<%=path%>/cms/layout/list" id="frmlayout">
							<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
								<thead class="th_nbw">
									<tr >
										<td width="40px" >
										</td>
							      		<td>
											框架名称
										</td>   
							      		<td>
											文件名称
										</td>   
							      		<td width="10%">
											排序号
										</td>   
							      		<td width="10%">
											是否公用
										</td>   
									</tr>
								</thead>
								<tbody>
									<tr class="template klId">
										<td width="40px" class="idCheck">
											<input type="checkbox" name="chklayout" class="klId" />
										</td>
							   		    <td class="klname niceTable-left"></td>
							   		    <td class="klfilename niceTable-left"></td>
							   		    <td width="10%" class="klorder_num niceTable-left"></td>
							   		    <td width="10%" class="klispub niceTable-left"></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td style="border-right: none">
											<img class="loading" 
												src="<%=path %>/resources/skins/default/images/large-loading.gif" width="20px"
												class="hidden" />
										</td>
										<td colspan="4" style="border-left: none" class="txtRight">
											<span class="pagediv"></span>
										</td>
									</tr>
								</tfoot>
							</table>
						</form>
		</div>
		<div id="tabs-2" style="overflow: scroll;height:250px">
						<form name="frmtemplate" method="post" style="margin: 0" action="<%=path%>/cms/template/list" id="frmtemplate">
							<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
								<thead class="th_nbw">
									<tr >
										<td width="40px" >
										</td>
							      		<td>
											模板名称
										</td>   
							      		<td>
											图片路径
										</td>   
							      		<td>
											模板路径
										</td>   
							      		<td>
											图片类型
										</td>   
							      		<td width="10%">
											是否公用
										</td>   
									</tr>
								</thead>
								<tbody>
									<tr class="template klId">
										<td width="40px" class="idCheck">
											<input type="checkbox" name="chktemplate" class="klId" />
										</td>
							   		    <td class="klname niceTable-left"></td>
							   		    <td class="klpicpath niceTable-left"></td>
							   		    <td class="klftlpath niceTable-left"></td>
							   		    <td class="klpictype niceTable-left"></td>
							   		    <td width="10%" class="klispub niceTable-left"></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td style="border-right: none">
											<img class="loading" 
												src="<%=path %>/resources/skins/default/images/large-loading.gif" width="20px"
												class="hidden" />
										</td>
										<td colspan="4" style="border-left: none" class="txtRight">
											<span class="pagediv"></span>
										</td>
									</tr>
								</tfoot>
							</table>
						</form>
		</div>
		<div id="tabs-3" style="overflow: scroll;height:250px">
						<form name="frmlookfeel" method="post" style="margin: 0" action="<%=path%>/cms/lookfeel/list" id="frmlookfeel">
							<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
								<thead class="th_nbw">
									<tr >
										<td width="40px" >
										</td>
							      		<td width="60%">
											皮肤名称
										</td>   
							      		<td>
											文件名称
										</td>   
							      		<td width="10%">
											排序号
										</td>   
							      		<td width="10%">
											是否公用
										</td>   
									</tr>
								</thead>
								<tbody>
									<tr class="template klId">
										<td width="40px" class="idCheck">
											<input type="checkbox" name="chkfunction" class="klId" />
										</td>
							   		    <td class="klname niceTable-left"></td>
							   		    <td class="klfilename niceTable-left"></td>
							   		    <td class="klorder_num niceTable-left"></td>
							   		    <td class="klispub niceTable-left"></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td style="border-right: none">
											<img class="loading"
												src="/resources/skins/default/images/large-loading.gif" width="20px"
												class="hidden" />
										</td>
										<td colspan="4" style="border-left: none" class="txtRight">
											<span class="pagediv"></span>
										</td>
									</tr>
								</tfoot>
							</table>
						</form>
		</div>
		<div id="tabs-4" style="overflow: scroll;height:250px">
						<form name="frmfunction" method="post" style="margin: 0" action="<%=path%>/cms/fun/list" id="frmfunction">
							<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
								<thead class="th_nbw">
									<tr >
										<td width="40px" >
											
										</td>
							      		<td width="60%">
											功能名称
										</td>   
							      		<td>
											功能编码
										</td>    
							      		<td width="10%">
											是否公用
										</td>   
									</tr>
								</thead>
								<tbody>
									<tr class="template klId">
										<td width="40px" class="idCheck">
											<input type="checkbox" name="chkfunction" class="klId" />
										</td>
							   		    <td class="klname niceTable-left"></td>
							   		    <td class="klfun_code niceTable-left"></td>
							   		    <td class="klispub niceTable-left"></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td style="border-right: none">
											<img class="loading"
												src="/resources/skins/default/images/large-loading.gif" width="20px"
												class="hidden" />
										</td>
										<td colspan="4" style="border-left: none" class="txtRight">
											<span class="pagediv"></span>
										</td>
									</tr>
								</tfoot>
							</table>
						</form>
		</div>
	</div>
</body>
